package test13;

import java.util.Scanner;

public class TicktacKtoe {
    private static Scanner input = new Scanner(System.in);
    public TicktacKtoe() {

    }
    public static void makeAMove(char[][] board, char player) {
        boolean done = false;
        do {
            System.out.print("玩家 " + player + " ：（行，列） = ");
            int row = input.nextInt();
            int column = input.nextInt();
            if (board[row][column] == '\0') {
                board[row][column] = player;
                done = true;
            }
            else
                System.out.println("无效输入");
        }
        while (!done);
    }
    public static void displayBoard(char[][] board) {
        System.out.println("\n ——— ——— ———");
        for (int i = 0; i < 3; i++) {
            System.out.print("| ");
            for (int j = 0; j < 3; j++)
                System.out.print(board[i][j] != '\0' ?  board[i][j] + " | ": "  | ");
            System.out.println("\n ——— ——— ———");
        }
    }
    public static boolean isWon(char ch, char[][] board) {
        for (int i = 0; i < 3; i++)
            if (ch == board[i][0] && ch == board[i][1] && ch == board[i][2])
                return true;
        for (int j = 0; j < 3; j++)
            if (ch == board[0][j] && ch == board[1][j] && ch == board[2][j])
                return true;
        if (ch == board[0][0] && ch == board[1][1] && ch == board[2][2])
            return true;
        return ch == board[0][2] && ch == board[1][1] && ch == board[2][0];
    }
    public static boolean isDraw(char[][] board) {
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (board[i][j] == '\0')
                    return false;
        return true;
    }
}

